package com.fengdao.demo.controller;

import com.fengdao.demo.model.UserEntity;
import com.fengdao.demo.pojo.UserReq;
import com.fengdao.demo.utils.StopWatchExpand;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/test")
@Api(tags = "测试")
public class TestController {


    @ApiOperationSupport(order = 2)
    @ApiOperation("测试接口")
    @GetMapping("/hello")
    public String hello() {
        return "hello";
    }


    @ApiOperationSupport(order = 1)
    @ApiOperation("测试实体")
    @PostMapping("/tetstEntity")
    public UserEntity tetstEntity(@RequestBody UserReq req) {
        StopWatchExpand.start("测试","开始-测试");
        UserEntity entity = new UserEntity(req.getUsername(), req.getPassword(), req.getId());
        StopWatchExpand.start("测试","测试全部完成");
        StopWatchExpand.stop();
        return entity;
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation("测试haha")
    @GetMapping("/haha")
    public String haha() {
        return "haha";
    }
}